using System;
using System.Collections;
using System.IO;
using System.Web;
using System.Web.UI.WebControls;
using GBPVR.Public;
namespace gbweb.classes
{
///
/// Summary description for ProgrammeDisplay.
///
///
///
public class ProgrammeDisplay2 : IDisposable
{
private string SortBy;
private string SecondarySortBy = "mrs_title";
private bool ExtendedEWAEnabled = false;
public ProgrammeDisplay2()
{
if (getExtendedEWA())
{
ExtendedEWA.OpenExtendedEWADB();
}
}
#region IDisposable Members
public void Dispose()
{
if (getExtendedEWA())
{
//Close the ExtendedEWA DB
ExtendedEWA.CloseExtendedEWADB();
}
}
#endregion
#region ExtendedEWA Detection
private static bool ExtendedEWAToolCheck;
private static bool ExtendedEWALoaded = false;
private static bool getExtendedEWA()
{
if (!ExtendedEWALoaded)
{
ExtendedEWAToolCheck = ExtendedEWA.Initialize();
ExtendedEWALoaded = true;
}
return ExtendedEWAToolCheck;
}
#endregion
public void FillProgrammeDisplay(HttpServerUtility Server, TableCell colShow, Programme programme, ScheduledRecording scheduledRecording, bool highlightRecordedShows)
{
//**************
//If you add functionality in this method you should review the FillProgrammeTreeArrayItem method as well
//**************
//
//This method fills a TableCell object with the formatted HTML code that is displayed
Settings guideParams = Global.Settings;
string title = string.Empty;
string subtitle = string.Empty;
string href = null;
string onclick = string.Empty;
bool externallinks = true;
string description = string.Empty;
bool showAsRecording = false;
if (scheduledRecording != null)
{
switch (scheduledRecording.getRecordingType())
{
case ScheduledRecording.TYPE_RECORD_ONCE:
if (programme == null)
{
if (scheduledRecording.getFileName() != null && scheduledRecording.getFileName().Length > 0)
{
title = "Manual Recording: " + scheduledRecording.getFileName();
}
else
{
title = "Manual Recording";
}
externallinks = false;
}
break;
default:
title = scheduledRecording.getFileName();
href = "Details2.aspx?rid=" + scheduledRecording.getOID();
onclick = " onclick=\"EditPop5(this.href,'Add2');return false;\"";
programme = null;
break;
}
if (highlightRecordedShows) showAsRecording = true;
}
ExtendedEWAEnabled = false;
const string new_show = "
New
";
const string wiki1 = "Wiki";
const string netflix1 = "Netflix";
const string tvcom1 = "TV.com";
const string imdb1 = "IMDB";
const string infoClass1 = "\n";
const string infoClass2 = "
\n";
string infoLinks = string.Empty;
string tooltip = string.Empty;
if (programme != null)
{
//Check to see if the ExtendedEWA DB is available
ExtendedEWAEnabled = getExtendedEWA();
title = programme.getTitle().Replace("\"", "''");
string extralinks = string.Empty;
const string spacer = "
";
// Show the programme description for all EPG Users
description = programme.getDescription().Replace("\"", "''");
if (description.Length > 0)
{
tooltip = description;
}
subtitle = programme.getSubTitle().Replace("\"", "''");
if (subtitle.Length > 0)
{
// If there's no description, then add the subtitle as the description
if (description.Length == 0 && !guideParams.showSubtitle)
{
tooltip = subtitle;
description = subtitle;
}
}
if (!guideParams.showDescription)
{
description = string.Empty;
}
// If you are not displaying the description but there is a subtitle then set the variable title to SubTitle
else if (guideParams.showSubtitle)
{
subtitle = programme.getSubTitle().Replace("\"", "''");
}
// Add a double line break if there are other things to display below the description
if ((guideParams.showGenre != "noGenre") || (guideParams.showRating) || (ExtendedEWAEnabled && (guideParams.showNew || guideParams.showCredits)))
{
description += spacer + " ";
}
// Retrieve the rating for the show
if (guideParams.showRating)
{
string rating = programme.getRating();
//Since this is the first item being added to the variable extalinks we don't need to add line breaks since it was taken care of by
if (rating != null && rating.Length > 0)
{
extralinks += "Rated: " + programme.getRating();
}
}
// Add the show Genre to the line
if (guideParams.showGenre != "noGenre")
{
ArrayList genreCheck = programme.getGenreList();
for (int unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()); unknownPos > -1;
unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()))
{
genreCheck.RemoveAt(unknownPos);
}
for (int unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()); unknownPos > -1;
unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()))
{
genreCheck.RemoveAt(unknownPos);
}
if (genreCheck.Count > 0)
{
//If another extralink was previously added we want to single space this one down otherwise no extra line is needed
if (extralinks.Length > 0) extralinks += "
";
if (guideParams.showGenre == "allGenre")
{
extralinks += "Genre" + (genreCheck.Count > 1 ? "s" : string.Empty) + ": " + string.Join(", ", (string[])genreCheck.ToArray(typeof(string)));
}
else
{
extralinks += "Genre: " + genreCheck[0];
}
}
}
// If the user has ExtendedEWA append additional information to the description when found
if (ExtendedEWAEnabled)
{
string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
// Pull the Airdate of the Show or the Release Year of the movie and the Start Rating for Movie
string[] programInfo = ExtendedEWA.GetProgramInfo(programUniqueIdentifier);
if (guideParams.showAirDate || guideParams.showStarRating)
{
if (programInfo.Length > 0)
{
if (programUniqueIdentifier.StartsWith("MV"))
{
if ((guideParams.showAirDate) && (programInfo[0] != "0"))
{
// If another extralink was previously added we want to single space this one down otherwise no extra line is needed
if (extralinks.Length > 0) extralinks += "
";
extralinks += " Movie Release Year: " + programInfo[0].ToString();
}
if ((guideParams.showStarRating) && (programInfo[2] != "none"))
{
// If another extralink was previously added we want to single space this one down otherwise no extra line is needed
if (extralinks.Length > 0) extralinks += "
";
extralinks += " Star Rating: " + programInfo[2];
}
}
else
{
if ((guideParams.showAirDate) && (programInfo[1] != "none"))
{
// If another extralink was previously added we want to single space this one down otherwise no extra line is needed
if (extralinks.Length > 0) extralinks += "
";
extralinks += " Original Air Date: " + programInfo[1];
}
}
}
}
// Check the ExtendedEWA supplemental database to see if the show is a new show
if (guideParams.showNew)
{
if (ExtendedEWA.IsNew(programUniqueIdentifier))
{
// If show is new tag an indicator at the end of the description indicating so
// If another extralink was previously added we want to single space this one down otherwise no extra line is needed
infoLinks += new_show;
}
//We need to check to see if the airdate is >= to today since the New show identifier is not reliable.
//If the airdate is >= programme air date then we can assume it is a new show
else if (programInfo.Length > 0)
{
if (!programUniqueIdentifier.StartsWith("MV"))
{
if (programInfo[1] != "none")
{
try
{
DateTime airDate = Convert.ToDateTime(programInfo[1]);
if (airDate.Date >= programme.getStartTime().Date)
{
infoLinks += new_show;
}
}
catch (Exception e)
{
}
}
}
}
}
// Check the ExtendedEWA supplemental database to see if the show is a new show
if (guideParams.showHD)
{
if (ExtendedEWA.IsHD(programUniqueIdentifier))
{
// If show is a High Def (HD) tag an indicator at the end of the description indicating the show is in HD
// If another extralink was previously added we want to single space this one down otherwise no extra line is needed
if (extralinks.Length > 0) extralinks += "
";
extralinks += " HD ";
}
}
// Provide a link to see Cast information
if (guideParams.showCredits)
{
// If another extralink was previously added we want to single space this one down otherwise no extra line is needed
if (extralinks.Length > 0) extralinks += "
";
extralinks += "(Credits)";
}
}
href = "Details2.aspx?id=" + programme.getOID();
if (scheduledRecording != null)
{
if (highlightRecordedShows) showAsRecording = true;
href += "&rid=" + scheduledRecording.getOID();
}
onclick = " onclick=\"EditPop5(this.href,'Add2');return false;\"";
if (extralinks != string.Empty)
{
description = description + extralinks;
}
}
else
{
if (scheduledRecording.getRecordingType() != ScheduledRecording.TYPE_RECORD_SEASON)
{
if (scheduledRecording.getFileName() != null && scheduledRecording.getFileName().Length > 0)
{
title = "Manual Recording: " + scheduledRecording.getFileName();
}
else
{
title = "Manual Recording";
}
externallinks = false;
}
}
// Add external links (these must be added in reverse order)
// Show the show link to Wikipedia for all EPG Users
if (externallinks && guideParams.showWiki)
{
infoLinks += wiki1 + "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=" + Server.UrlEncode(title) + "\" target=\"_blank\"" + wiki2;
//description = " (Wiki)" + description;
}
// Show the show link to TV.Com for all EPG Users
if (externallinks && guideParams.showTVCom)
{
infoLinks += tvcom1 + "http://www.google.com/search?hl=en&q=site%3Awww.tv.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"" + tvcom2;
//description = " (TV.Com)" + description;
}
// Show the show link to Netflix for all EPG Users
if (externallinks && guideParams.showNetflix)
{
string tmpNet = string.Empty;
if (programme != null)
{
string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
if (programUniqueIdentifier.StartsWith("MV"))
{
if (ExtendedEWAEnabled)
{
ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
if (cast.Count > 0)
{
ExtendedEWA.Crew crew = (ExtendedEWA.Crew) cast[0];
tmpNet = "http://www.google.com/search?hl=en&q=site%3Awww.netflix.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (NetFlix)" + description;
}
else
{
tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (Netflix)" + description;
}
}
else
{
tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (Netflix)" + description;
}
}
else
{
tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (Netflix)" + description;
}
}
else
{
tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (Netflix)" + description;
}
infoLinks += netflix1+ tmpNet + netflix2;
}
// Show the show link to IMDB for all EPG Users
if (externallinks && guideParams.showIMDB)
{
string tmpIMDB = string.Empty;
if (programme != null)
{
if (subtitle != null && subtitle != "")
{
tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
else
{
if (ExtendedEWAEnabled)
{
string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
if (cast.Count > 0)
{
ExtendedEWA.Crew crew = (ExtendedEWA.Crew) cast[0];
if (programUniqueIdentifier.StartsWith("MV"))
{
tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "+%22Directed+by%22+-%22date+of+birth%22&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
else
{
tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+%22TV-Series%22+&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
}
else
{
tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
}
else
{
tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
}
}
else
{
tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
infoLinks += imdb1 + tmpIMDB + imdb2;
}
if (showAsRecording)
{
int showStatus = scheduledRecording.getRecordingStatus();
switch (showStatus)
{
case ScheduledRecording.STATUS_PENDING:
colShow.CssClass = "listingPending";
break;
case ScheduledRecording.STATUS_IN_PROGRESS:
colShow.CssClass = "listingInProgress";
break;
case ScheduledRecording.STATUS_COMPLETED:
colShow.CssClass = "listingAvailable";
break;
case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
colShow.CssClass = "listingFailed";
break;
case ScheduledRecording.STATUS_CONFLICT:
colShow.CssClass = "listingConflict";
break;
default:
colShow.CssClass = "listingAvailable";
break;
}
}
else
{
colShow.CssClass = "listing";
}
if (href != null)
{
if (subtitle.Length > 0)
{
title = "\n";
}
else
{
title = "\n";
}
}
else
{
if (subtitle.Length > 0)
{
title = "" + title + "
" + "" + subtitle + "
\n";
}
else
{
title = "" + title + "
\n";
}
}
if (description.Length > 0) title += "" + description + "
\n";
if (infoLinks.Length > 0)
{
title = infoClass1 + infoLinks + infoClass2 + title;
}
colShow.Text = title;
}
public void FillProgrammeTreeArrayItem(ProgramTreeItem treeItem, HttpServerUtility Server, Programme programme, ScheduledRecording scheduledRecording, bool highlightRecordedShows, Channel channel)
{
//**************
//If you add functionality in this method you should review the FillProgramme method as well
//**************
//
//This method fills a ProgrammeTreeItem object with the formatted HTML code that is displayed
Settings guideParams = Global.Settings;
string title = string.Empty;
string subtitle = string.Empty;
string title2 = string.Empty;
string subtitle2 = string.Empty;
string href = string.Empty;
string onclick = string.Empty;
string description = string.Empty;
bool showAsRecording = false;
bool ManualRecording = false;
bool externallinks = false;
if (scheduledRecording != null)
{
if (highlightRecordedShows) showAsRecording = true;
}
ExtendedEWAEnabled = false;
const string new_show = "New
";
const string wiki1 = "Wiki";
const string netflix1 = "Netflix";
const string tvcom1 = "TV.com";
const string imdb1 = "IMDB";
const string infoClass1 = "\n";
const string infoClass2 = "
\n";
string infoLinks = string.Empty;
string tooltip = string.Empty;
if (programme != null)
{
externallinks = true;
//Check to see if the ExtendedEWA DB is available
ExtendedEWAEnabled = getExtendedEWA();
//Set the onclick event variable
onclick = " onclick=\"EditPop5(this.href,'Add2');return false;\"";
//Set the Title and Subtitle variables
title = programme.getTitle().Replace("\"", "''");
subtitle = programme.getSubTitle().Replace("\"", "''");
title2 = programme.getTitle().Replace("\"", "''");
subtitle2 = programme.getSubTitle().Replace("\"", "''");
tooltip = string.Empty;
description = programme.getDescription().Replace("\"", "''");
if (description.Length > 0)
{
tooltip = description;
treeItem.setDescription("" + description + "\n");
}
if (subtitle.Length > 0)
{
// If there's no description, then add the subtitle as the description
if (description.Length == 0 && !guideParams.showSubtitle)
{
tooltip = subtitle;
description = subtitle;
treeItem.setDescription("" + description + "\n");
}
}
treeItem.setTitle("" + title + "
\n");
treeItem.setRawTitle(programme.getTitle().Replace("\"", "''"));
string subtitleFmt;
if (subtitle.Length > 0)
{
subtitleFmt = "Subtitle: ";
subtitleFmt += "" + subtitle + "\n";
}
else
{
subtitleFmt = "Subtitle: ";
subtitleFmt += "None Available\n";
}
treeItem.setSubTitle(subtitleFmt);
// Retrieve the rating for the show
if (guideParams.showRating)
{
string rating = programme.getRating();
//Since this is the first item being added to the variable extalinks we don't need to add line breaks since it was taken care of by
if (rating != null && rating.Length > 0)
{
treeItem.setRating("" + "Rated: " + programme.getRating() + "");
}
}
// Add the show Genre
if (guideParams.showGenre != "noGenre")
{
ArrayList genreCheck = programme.getGenreList();
for (int unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()); unknownPos > -1;
unknownPos = genreCheck.BinarySearch("unknown", new CaseInsensitiveComparer()))
{
genreCheck.RemoveAt(unknownPos);
}
for (int unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()); unknownPos > -1;
unknownPos = genreCheck.BinarySearch(string.Empty, new CaseInsensitiveComparer()))
{
genreCheck.RemoveAt(unknownPos);
}
if (genreCheck.Count > 0)
{
//If another extralink was previously added we want to single space this one down otherwise no extra line is needed
if (guideParams.showGenre == "allGenre")
{
treeItem.setGenre("" + "Genre" + (genreCheck.Count > 1 ? "s" : string.Empty) + ": " + string.Join(", ", (string[])genreCheck.ToArray(typeof(string))) + "");
}
else
{
treeItem.setGenre("" + "Genre: " + genreCheck[0] + "");
}
}
else
{
treeItem.setGenre("" + "No Genre Found:" + "");
}
}
// If the user has ExtendedEWA append additional information to the description when found
if (ExtendedEWAEnabled)
{
string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
// Pull the Airdate of the Show or the Release Year of the movie and the Start Rating for Movie
string[] programInfo = ExtendedEWA.GetProgramInfo(programUniqueIdentifier);
if (guideParams.showAirDate || guideParams.showStarRating)
{
if (programInfo.Length > 0)
{
if (programUniqueIdentifier.StartsWith("MV"))
{
if ((guideParams.showAirDate) && (programInfo[0] != "0"))
{
treeItem.setReleaseYear("" + "Movie Release Year: " + programInfo[0].ToString() + "");
}
if ((guideParams.showStarRating) && (programInfo[2] != "none"))
{
treeItem.setStarRating("" + "Star Rating: " + programInfo[2] + "");
}
}
else
{
if ((guideParams.showAirDate) && (programInfo[1] != "none"))
{
treeItem.setOriginalAirDate("" + "Original Air Date: " + programInfo[1] + "");
treeItem.setRawOriginalAirDate(programInfo[1]);
}
}
}
}
// Check the ExtendedEWA supplemental database to see if the show is a new show
if (guideParams.showNew)
{
if (ExtendedEWA.IsNew(programUniqueIdentifier))
{
treeItem.setNew_Show("New");
}
//We need to check to see if the airdate is >= to today since the New show identifier is not reliable.
//If the airdate is >= programme air date then we can assume it is a new show
else if (programInfo.Length > 0)
{
if (!programUniqueIdentifier.StartsWith("MV"))
{
if (programInfo[1] != "none")
{
try
{
DateTime airDate = Convert.ToDateTime(programInfo[1]);
if (airDate.Date >= programme.getStartTime().Date)
{
treeItem.setNew_Show("New");
}
}
catch (Exception e)
{
}
}
}
}
}
if (guideParams.showHD)
{
if (ExtendedEWA.IsHD(programUniqueIdentifier))
{
// If show is a High Def (HD) tag an indicator at the end of the description indicating the show is in HD
// If another extralink was previously added we want to single space this one down otherwise no extra line is needed
treeItem.setHD("" + " HD " + "");
}
}
// Provide a link to see Cast information
if (guideParams.showCredits)
{
treeItem.setCredits("" + "Credits" + "");
}
}
if (showAsRecording)
{
int showStatus = scheduledRecording.getRecordingStatus();
switch (showStatus)
{
case ScheduledRecording.STATUS_PENDING:
treeItem.setRecordingDisplayClass("treelistingPending");
treeItem.setStatus("Pending");
break;
case ScheduledRecording.STATUS_IN_PROGRESS:
treeItem.setRecordingDisplayClass("treelistingInProgress");
treeItem.setStatus("In-Progress");
break;
case ScheduledRecording.STATUS_COMPLETED:
treeItem.setRecordingDisplayClass("treelistingAvailable");
treeItem.setStatus("Available");
break;
case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
treeItem.setRecordingDisplayClass("treelistingFailed");
treeItem.setStatus("Failed");
break;
case ScheduledRecording.STATUS_CONFLICT:
treeItem.setRecordingDisplayClass("treelistingConflict");
treeItem.setStatus("Conflict");
break;
case ScheduledRecording.STATUS_PLACE_HOLDER:
treeItem.setRecordingDisplayClass("treelistingReocurring");
treeItem.setStatus("Reocurring");
break;
default:
treeItem.setRecordingDisplayClass("listing");
treeItem.setStatus("Unknown");
break;
}
}
else
{
treeItem.setRecordingDisplayClass("listing");
}
treeItem.setAirDate("" + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString() + "");
treeItem.setrawAirDateStartTime(programme.getStartTime());
treeItem.setrawAirDateEndTime(programme.getEndTime());
if (channel != null)
{
treeItem.setChannelDisplay("" + channel.getName() + "");
treeItem.setChannelName(channel.getName());
treeItem.setChannel(channel.getChannelNumber());
}
else
{
treeItem.setChannelDisplay("No Channel Info Found 1");
treeItem.setChannelName("No Channel Info Found 1");
}
href = "Details2.aspx?id=" + programme.getOID();
if (scheduledRecording != null)
{
href += "&rid=" + scheduledRecording.getOID();
}
}
else
{
ManualRecording = true;
string subtitleFmt = string.Empty;
if (scheduledRecording.getRecordingType() != ScheduledRecording.TYPE_RECORD_SEASON)
{
treeItem.setGenre("" + "Genre: Manual Recording" + "");
if (scheduledRecording.getFileName() != null && scheduledRecording.getFileName().Length > 0)
{
title = "Manual Recording: ";
subtitleFmt = "" + "Subtitle: " + "";
subtitleFmt += "" + scheduledRecording.getFileName() + "";
}
else
{
title = "Manual Recording";
subtitleFmt = "" + "Subtitle: " + "";
subtitleFmt += "" + "None Available" + "";
}
}
else
{
title = scheduledRecording.getFileName();
href = "Details2.aspx?rid=" + scheduledRecording.getOID();
title = "" + title + "";
treeItem.setTitle(" " + title + "");
treeItem.setGenre("" + "Genre: Season Recording" + "");
if (scheduledRecording.getStartTime().Year != 0001)
{
subtitleFmt = "" + scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString() + "";
}
externallinks = false;
}
treeItem.setTitle(" " + title + "");
treeItem.setRawTitle(title);
treeItem.setSubTitle(subtitleFmt);
if (showAsRecording)
{
int showStatus = scheduledRecording.getRecordingStatus();
switch (showStatus)
{
case ScheduledRecording.STATUS_PENDING:
treeItem.setRecordingDisplayClass("treelistingPending");
treeItem.setStatus("Pending");
break;
case ScheduledRecording.STATUS_IN_PROGRESS:
treeItem.setRecordingDisplayClass("treelistingInProgress");
treeItem.setStatus("In-Progress");
break;
case ScheduledRecording.STATUS_COMPLETED:
treeItem.setRecordingDisplayClass("treelistingAvailable");
treeItem.setStatus("Available");
break;
case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
treeItem.setRecordingDisplayClass("treelistingFailed");
treeItem.setStatus("Failed");
break;
case ScheduledRecording.STATUS_CONFLICT:
treeItem.setRecordingDisplayClass("treelistingConflict");
treeItem.setStatus("Conflict");
break;
case ScheduledRecording.STATUS_PLACE_HOLDER:
treeItem.setRecordingDisplayClass("treelistingReocurring");
treeItem.setStatus("Reocurring");
break;
default:
treeItem.setRecordingDisplayClass("listing");
treeItem.setStatus("Unknown");
break;
}
}
else
{
treeItem.setRecordingDisplayClass("listing");
}
if (channel != null)
{
treeItem.setChannelDisplay("" + channel.getName() + "");
treeItem.setChannelName(channel.getName());
treeItem.setChannel(channel.getChannelNumber());
}
else
{
treeItem.setChannelDisplay("No Channel Info Found 2");
treeItem.setChannelName("No Channel Info Found 2");
}
}
// Add external links (these must be added in reverse order)
// Show the show link to Wikipedia for all EPG Users
if (guideParams.showWiki && externallinks)
{
infoLinks += wiki1 + "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=" + Server.UrlEncode(title) + "\" target=\"_blank\"" + wiki2;
}
// Show the show link to TV.Com for all EPG Users
if (guideParams.showTVCom && externallinks)
{
infoLinks += tvcom1 + "http://www.google.com/search?hl=en&q=site%3Awww.tv.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"" + tvcom2;
}
// Show the show link to Netflix for all EPG Users
if (guideParams.showNetflix && externallinks)
{
string tmpNet = string.Empty;
string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
if (programUniqueIdentifier.StartsWith("MV"))
{
if (ExtendedEWAEnabled)
{
ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
if (cast.Count > 0)
{
ExtendedEWA.Crew crew = (ExtendedEWA.Crew)cast[0];
tmpNet = "http://www.google.com/search?hl=en&q=site%3Awww.netflix.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (NetFlix)" + description;
}
else
{
tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (Netflix)" + description;
}
}
else
{
tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (Netflix)" + description;
}
}
else
{
tmpNet = "http://www.netflix.com/Search?dtl=1&type=title&v1=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (Netflix)" + description;
}
infoLinks += netflix1 + tmpNet + netflix2;
}
// Show the show link to IMDB for all EPG Users
if (guideParams.showIMDB && externallinks)
{
string tmpIMDB = string.Empty;
if (subtitle != null && subtitle != "")
{
tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(subtitle) + "&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
else
{
if (ExtendedEWAEnabled)
{
string programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
ArrayList cast = ExtendedEWA.GetCast(programUniqueIdentifier);
if (cast.Count > 0)
{
ExtendedEWA.Crew crew = (ExtendedEWA.Crew)cast[0];
if (programUniqueIdentifier.StartsWith("MV"))
{
tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+" + Server.UrlEncode(crew.GivenName) + "+" + Server.UrlEncode(crew.SurName) + "+%22Directed+by%22+-%22date+of+birth%22&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
else
{
tmpIMDB = "http://www.google.com/search?hl=en&q=site%3Awww.imdb.com+" + Server.UrlEncode(title) + "+%22TV-Series%22+&btnI=I%27m+Feeling+Lucky" + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
}
else
{
tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
}
else
{
tmpIMDB = "http://www.imdb.com/find?s=tt&q=" + Server.UrlEncode(title) + "\" target=\"_blank\"";
//description = " (IMDB)" + description;
}
}
infoLinks += imdb1 + tmpIMDB + imdb2;
}
treeItem.setTitle("" + treeItem.title + "");
if (!ManualRecording)
{
treeItem.setChannelDisplay("" + treeItem.channelDisplay + "");
}
try
{
treeItem.setProgrammeOID(programme.getOID().ToString());
}
catch(Exception ex)
{
}
string options = "";
bool strmAllowed = File.Exists(Path.Combine(guideParams.strmVLCLoc, "vlc.exe"));
try
{
switch (scheduledRecording.getRecordingStatus())
{
case ScheduledRecording.STATUS_PENDING:
options = "
Cancel Recording
";
treeItem.setButtonOptions(options);
break;
case ScheduledRecording.STATUS_IN_PROGRESS:
options = "
Play Program" +
"Download";
if (strmAllowed)
{
options += "Stream";
}
if (programme == null)
{
options += "Cancel Recording";
}
options += "
";
treeItem.setButtonOptions(options);
break;
case ScheduledRecording.STATUS_COMPLETED:
options = "
Play Program" +
"Download";
if (strmAllowed)
{
options += "Stream";
}
if (programme == null)
{
options += "Delete";
}
options += "
";
treeItem.setButtonOptions(options);
break;
case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
options = "
Delete
";
treeItem.setButtonOptions(options);
break;
case ScheduledRecording.STATUS_CONFLICT:
options = "
";
treeItem.setButtonOptions(options);
break;
case ScheduledRecording.STATUS_PLACE_HOLDER:
options = "
Cancel Recording
";
treeItem.setButtonOptions(options);
break;
case ScheduledRecording.STATUS_DELETED:
options = "
" + "Deleted" + "
";
treeItem.setButtonOptions(options);
break;
default:
treeItem.setButtonOptions("NONE!!");
break;
}
}
catch(Exception ex)
{
}
}
public void FillProgrammeTree(TreeView treeView, ProgramTreeItem[] treeItemArray, string sortBy, string secondarySortBy)
{
SecondarySortBy = secondarySortBy;
FillProgrammeTree(treeView, treeItemArray, sortBy);
}
public void FillProgrammeTree(TreeView treeView, ProgramTreeItem [] treeItemArray, string sortBy)
{
SortBy = sortBy;
//**************
//This method Sorts and then loops through an Array of ProgrammeTreeItems to load them into
//a Treview control that is passed in.
//**************
//
//Pull in the global settings
Settings guideParams = Global.Settings;
//Create a new sort object for the arrary of TreeItems
ProgramTreeItem_Sort sortArray;
//Initialize the sort object with the correct sort parameter that defines what order the items will
//be sorted in
switch (SecondarySortBy)
{
case "mrs_title":
{
switch (sortBy)
{
case "title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "originalAirDate":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByOriginalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_channel":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByChannel, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_status":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStatus, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_original_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByOrignalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
default:
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
}
break;
}
case "mrs_date":
{
switch (sortBy)
{
case "title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_channel":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByChannel, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_status":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStatus, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_original_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByOrignalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
default:
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
}
break;
}
default:
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
}
//Sort the array of TreeItems using the custom sort object
Array.Sort(treeItemArray, sortArray);
//Initialize looping variables to 0
int idx1 = 0;
int idx2 = 0;
//Initialize all the display nodes for the tree
TreeNode alternateRoot = new TreeNode();
TreeNode root = new TreeNode();
TreeNode child1 = new TreeNode();
TreeNode child2 = new TreeNode();
TreeNode child3 = new TreeNode();
TreeNode child4 = new TreeNode();
TreeNode child5 = new TreeNode();
TreeNode child6 = new TreeNode();
TreeNode child7 = new TreeNode();
TreeNode child8 = new TreeNode();
TreeNode child9 = new TreeNode();
TreeNode child10 = new TreeNode();
TreeNode child11 = new TreeNode();
TreeNode child12 = new TreeNode();
//Loop through all the TreeItems in the array....building the TreeView
while (idx1 < treeItemArray.Length)
{
//Set idx2 to the previous index number....this is used to compare the current item to the
//previous item that was loaded into the tree....this tells us where to break to build a new node
idx2 = idx1 - 1;
//Set variable treeItem1 to the first array object
ProgramTreeItem treeItem1 = treeItemArray[idx1];
//Initialize the variable treeItem2
ProgramTreeItem treeItem2 = new ProgramTreeItem();
//We only want to set the variable treeItem2 to the previous item in the array if we have already
//loaded the first item in the array....so if the previous index number (idx2) is 0 or greater we
//have processed the first item in the array already
if (idx2 > -1)
{
treeItem2 = treeItemArray[idx2];
}
//If we are on the first item in the array then we need to load the info into the TreeView and move
//on to processing the next array item
if (idx1 == 0)
{
//If the sort is on anything but title we have to build the main grouper node
if (sortBy != "title" && sortBy != "mr_title")
{
if (sortBy == "status" || sortBy == "mr_status")
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Set the node text to the current Status.
alternateRoot.Text = treeItem1.status;
}
else if (sortBy == "channel" || sortBy == "mr_channel")
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Set the node text to the current Channel
alternateRoot.Text = treeItem1.channelName;
}
else if (sortBy == "originalAirDate" || sortBy == "mr_original_date")
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Set the node text to the original air date
if (guideParams.showAirDate)
{
if (treeItem1.rawOriginalAirDate != null)
{
alternateRoot.Text = treeItem1.originalAirDate;
}
else
{
alternateRoot.Text = "No Original Air Date Found:";
}
}
else
{
alternateRoot.Text = "Original Air Date not selected to display in Configuration Tab:";
}
}
else if (sortBy == "genre" || sortBy == "mr_genre")
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Check to see if the user has selected to show Genre or not....if not then give them
//a message indicating this.....otherwise set the node text to the current Genre.
if (guideParams.showGenre != "noGenre")
{
alternateRoot.Text = treeItem1.genre;
}
else
{
alternateRoot.Text = "Genre not selected to display in Configuration Tab:";
}
}
else if (sortBy == "rating" || sortBy == "mr_rating")
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Check to see if the user has selected to show Rating or not....if not then give them
//a message indicating this.....otherwise set the node text to the current Rating.
if (guideParams.showRating)
{
if (treeItem1.rating != null)
{
alternateRoot.Text = treeItem1.rating;
}
else
{
alternateRoot.Text = "No Rating Found:";
}
}
else
{
alternateRoot.Text = "Rating not selected to display in Configuration Tab:";
}
}
else if (sortBy == "star" || sortBy == "mr_star")
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Check to see if the user has selected to show Star Rating or not....if not then give them
//a message indicating this.....otherwise set the node text to the current Star Rating.
if (guideParams.showStarRating)
{
if (treeItem1.starRating != null)
{
alternateRoot.Text = treeItem1.starRating;
}
else
{
alternateRoot.Text = "No Star Rating Found:";
}
}
else
{
alternateRoot.Text = " Star Rating not selected to display in Configuration Tab:";
}
}
else if (sortBy == "date")
{
//Set the grouper node to not do anything when the text of the node is clicked onalternateRoot.SelectAction = TreeNodeSelectAction.None;
if (treeItem1.rawAirDateStartTime != null)
{
alternateRoot.Text = treeItem1.airDate;
}
else
{
alternateRoot.Text = "No Air Date Found:";
}
}
else if (sortBy == "mr_date")
{
//Set the grouper node to not do anything when the text of the node is clicked onalternateRoot.SelectAction = TreeNodeSelectAction.None;
if (treeItem1.rawAirDateStartTime != null)
{
alternateRoot.Text = treeItem1.rawAirDateStartTime.ToLongDateString();
}
else
{
alternateRoot.Text = "No Air Date Found:";
}
}
}
//Fill a complete TreeView Item including the top level of the item
root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
child6, child7, child8, child9, child10, child11, child12, true);
}
else
{
//This code is executed for the second item in the array through the end of the array
//
//If you are either not sorting by the date or if you are sorting by the date and both the current
//item and the previous item have the same air date then we do not need to break for a new node
if ((sortBy == "date" && treeItem1.rawAirDateStartTime == treeItem2.rawAirDateStartTime) ||
(sortBy == "mr_date" && treeItem1.rawAirDateStartTime.ToLongDateString() == treeItem2.rawAirDateStartTime.ToLongDateString()) ||
(sortBy == "mr_originalDate" && treeItem1.rawOriginalAirDate == treeItem2.rawOriginalAirDate) ||
(sortBy == "originalAirDate" && treeItem1.rawOriginalAirDate == treeItem2.rawOriginalAirDate) ||
(sortBy == "mr_channel" && treeItem1.channel == treeItem2.channel) ||
(sortBy == "mr_status" && treeItem1.status == treeItem2.status) ||
(sortBy != "mr_original_Date" && sortBy != "originalAirDate" && sortBy != "date" && sortBy != "mr_date" && sortBy != "mr_channel" && sortBy != "mr_status"))
{
//If the titles of the current and previous item match there is no need to break for a new node
if (treeItem1.rawTitle == treeItem2.rawTitle)
{
//If the subtitles of the current and previous item match there is no need to break for a
//new node
if (treeItem1.subtitle == treeItem2.subtitle)
{
if (treeItem1.description == treeItem2.description)
{
//If this item has a status such as recorded, failed, etc then we need to replace the text so that
//it displays with the correct highlighting which is stored in the RecordingDisplayClaiss of the treeItem.
if (treeItem1.getRecordingDisplayClass() != "listing")
{
child1.Text =
child1.Text.Replace("class=\"listing\"",
"class=\"" + treeItem1.displayClass + "\"");
child1.Text =
child1.Text.Replace("class=\"showSubtitle\"",
"class=\"" + treeItem1.displayClass + "\"");
}
//if the current and previous items are not on the same date we want to have a node
//break so that we have a node for each date the show is airing on
if (treeItem1.rawAirDateStartTime != treeItem2.rawAirDateStartTime)
{
//Initialize the two treenodes that are needed
child11 = new TreeNode();
child12 = new TreeNode();
//Set the airdate to display
FillProgrammeTreeAirDate(treeItem1, child11);
//Set this node to do nothing when the text is clicked on
child11.SelectAction = TreeNodeSelectAction.None;
//We want this node to be expanded automatically
child11.Expand();
//If this item has a status such as recorded, failed, etc then we need to replace the text so that
//it displays with the correct highlighting which is stored in the RecordingDisplayClaiss of the treeItem.
if (treeItem1.displayClass != "listing")
{
child11.Text =
child11.Text.Replace("class=\"listing\"",
"class=\"" + treeItem1.displayClass + "\"");
}
//Add the node to the tree
child1.ChildNodes.Add(child11);
//Set the channel info in the node
FillProgrammeTreeChannel(treeItem1, child12);
//Set the text in the node to do nothing when clicked on
child12.SelectAction = TreeNodeSelectAction.None;
//If the treeitem does not have any recording status then we want to let the user
//select to record the show by using a checkbox
if (treeItem1.displayClass == "listing")
{
child12.ShowCheckBox = true;
}
//Add the node to the tree
child11.ChildNodes.Add(child12);
}
else
{
//Since the airdates for the current and previous items matched we only need to create
//a node for the channel that the show is displaying on
//
//Initialize the treenode is needed
child12 = new TreeNode();
//Set the channel info in the node
FillProgrammeTreeChannel(treeItem1, child12);
//Set the text in the node to do nothing when clicked on
//If the treeitem does not have any recording status then we want to let the user
//select to record the show by using a checkbox
child12.SelectAction = TreeNodeSelectAction.None;
if (treeItem1.displayClass == "listing")
{
child12.ShowCheckBox = true;
}
child11.ChildNodes.Add(child12);
}
}
else
{
//Since the descriptions are different between the current item and the previous item we
//need to create a new node for all the show info. However, since the Titles match
//we do not create a new main root node.
child1 = new TreeNode();
child2 = new TreeNode();
child3 = new TreeNode();
child4 = new TreeNode();
child5 = new TreeNode();
child6 = new TreeNode();
child7 = new TreeNode();
child8 = new TreeNode();
child9 = new TreeNode();
child10 = new TreeNode();
child11 = new TreeNode();
child12 = new TreeNode();
root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
child6, child7, child8, child9, child10, child11, child12, false);
}
}
else
{
//Since the subtitles are different between the current item and the previous item we
//need to create a new node for all the show info. However, since the Titles match
//we do not create a new main root node.
child1 = new TreeNode();
child2 = new TreeNode();
child3 = new TreeNode();
child4 = new TreeNode();
child5 = new TreeNode();
child6 = new TreeNode();
child7 = new TreeNode();
child8 = new TreeNode();
child9 = new TreeNode();
child10 = new TreeNode();
child11 = new TreeNode();
child12 = new TreeNode();
root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
child6, child7, child8, child9, child10, child11, child12, false);
}
}
else
{
//Since the Titles of the current and previous item do not match we need to create a
//new node to hold all the show info
//
//If we are not sorting by title then we are grouping by some other characteristic.
if (sortBy != "title" && sortBy != "mr_title")
{
//Add the new node to the grouping node (alternateRoot)
alternateRoot.ChildNodes.Add(root);
//If the grouping item is different between the current item and the previous item then
//we need to create a new grouping node
if (sortBy == "mr_status")
{
if (treeItem1.status != treeItem2.status)
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Set the node text to the current Status.
alternateRoot.Text = treeItem1.status;
}
}
else if (sortBy == "mr_channel")
{
if (treeItem1.channel != treeItem2.channel)
{
//Set the grouper node to not do anything when the text of the node is clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Set the node text to the current Channel
alternateRoot.Text = treeItem1.channelName;
}
}
else if (sortBy == "genre" || sortBy == "mr_genre")
{
if (treeItem1.genre != treeItem2.genre)
{
//Add the grouping node to the treeview
treeView.Nodes.Add(alternateRoot);
//Initialize a new grouping node
alternateRoot = new TreeNode();
//set the grouping node to do nothing when the text of the node is selected
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Check to see if the user has selected to show Genre or not....if not then give them
//a message indicating this.....otherwise set the node text to the current Genre.
if (guideParams.showGenre != "noGenre")
{
alternateRoot.Text = treeItem1.genre;
}
else
{
alternateRoot.Text = "Genre not selected to display in Configuration Tab:";
}
}
}
else if (sortBy == "rating" || sortBy == "mr_rating")
{
if (treeItem1.rating != treeItem2.rating)
{
//Add the grouping node to the treeview
treeView.Nodes.Add(alternateRoot);
//Initialize a new grouping node
alternateRoot = new TreeNode();
//set the grouping node to do nothing when the text of the node is selected
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Check to see if the user has selected to show Rating or not....if not then give them
//a message indicating this.....otherwise set the node text to the current Rating.
if (guideParams.showRating)
{
if (treeItem1.rating != null)
{
alternateRoot.Text = treeItem1.rating;
}
else
{
alternateRoot.Text = "No Rating Found:";
}
}
else
{
alternateRoot.Text = "Rating not selected to display in Configuration Tab:";
}
}
}
else if (sortBy == "star" || sortBy == "mr_star")
{
if (treeItem1.starRating != treeItem2.starRating)
{
//Add the grouping node to the treeview
treeView.Nodes.Add(alternateRoot);
//Initialize a new grouping node
alternateRoot = new TreeNode();
//set the grouping node to do nothing when the text of the node is selected
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Check to see if the user has selected to show Star Rating or not....if not then give them
//a message indicating this.....otherwise set the node text to the current Star Rating.
if (guideParams.showStarRating)
{
if (treeItem1.starRating != null)
{
alternateRoot.Text = treeItem1.starRating;
}
else
{
alternateRoot.Text = "No Star Rating Found:";
}
}
else
{
alternateRoot.Text = "Star Rating not selected to display in Configuration Tab:";
}
}
}
else if (sortBy == "originalAirDate" || sortBy == "mr_original_date")
{
if (treeItem1.rawOriginalAirDate != treeItem2.rawOriginalAirDate)
{
//Add the grouping node to the treeview
treeView.Nodes.Add(alternateRoot);
//Initialize a new grouping node
alternateRoot = new TreeNode();
//set the grouping node to do nothing when the text of the node is selected
alternateRoot.SelectAction = TreeNodeSelectAction.None;
//Check to see if the user has selected to show Star Rating or not....if not then give them
//a message indicating this.....otherwise set the node text to the current Star Rating.
if (guideParams.showAirDate)
{
if (treeItem1.rawOriginalAirDate != null)
{
alternateRoot.Text = treeItem1.originalAirDate;
}
else
{
alternateRoot.Text = "No Orignal Air Date Found:";
}
}
else
{
alternateRoot.Text = "Orignal Air Date not selected to display in Configuration Tab:";
}
}
}
else if (sortBy == "date")
{
if (treeItem1.rawAirDateStartTime != treeItem2.rawAirDateStartTime ||
(treeItem1.rawAirDateStartTime == treeItem2.rawAirDateStartTime && treeItem1.rawAirDateEndTime != treeItem2.rawAirDateEndTime))
{
//Add the grouping node to the treeview
treeView.Nodes.Add(alternateRoot);
//Initialize a new grouping node
alternateRoot = new TreeNode();
//set the grouping node to do nothing when the text of the node is selected
alternateRoot.SelectAction = TreeNodeSelectAction.None;
if (treeItem1.rawAirDateStartTime != null)
{
alternateRoot.Text = treeItem1.airDate;
}
else
{
alternateRoot.Text = "No Air Date Found:";
}
}
}
else if (sortBy == "mr_date")
{
if (treeItem1.rawAirDateStartTime.ToLongDateString() != treeItem2.rawAirDateStartTime.ToLongDateString())
{
//Add the grouping node to the treeview
treeView.Nodes.Add(alternateRoot);
//Initialize a new grouping node
alternateRoot = new TreeNode();
//set the grouping node to do nothing when the text of the node is selected
alternateRoot.SelectAction = TreeNodeSelectAction.None;
if (treeItem1.rawAirDateStartTime != null)
{
alternateRoot.Text = treeItem1.rawAirDateStartTime.ToLongDateString();
}
else
{
alternateRoot.Text = "No Air Date Found:";
}
}
}
}
else
{
//Since we are sorting by title we just add the node to the TreeView
treeView.Nodes.Add(root);
}
//Initalize the nodes
root = new TreeNode();
child1 = new TreeNode();
child2 = new TreeNode();
child3 = new TreeNode();
child4 = new TreeNode();
child5 = new TreeNode();
child6 = new TreeNode();
child7 = new TreeNode();
child8 = new TreeNode();
child9 = new TreeNode();
child10 = new TreeNode();
child11 = new TreeNode();
child12 = new TreeNode();
//Fill the intialized nodes with the info in the current item. Since this is a non-matching
//item then we also initialize the main root node.
root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
child6, child7, child8, child9, child10, child11, child12, true);
}
}
else
{
//Since we are soting by date and the dates of the current and previous item do not match we
//need to make a break and create a new node to hold the info
//
//Add the node to the grouping node
alternateRoot.ChildNodes.Add(root);
//Add the grouping node to the TreeView
treeView.Nodes.Add(alternateRoot);
//Initialize a new grouping node
alternateRoot = new TreeNode();
//Set the grouping node text to do nothing when clicked on
alternateRoot.SelectAction = TreeNodeSelectAction.None;
if (sortBy == "mr_date" || sortBy == "date")
{
if (treeItem1.rawAirDateStartTime != null)
{
if (sortBy == "mr_date")
{
alternateRoot.Text = treeItem1.rawAirDateStartTime.ToLongDateString();
}
else
{
alternateRoot.Text = treeItem1.airDate;
}
}
else
{
alternateRoot.Text = "No Air Date Found:";
}
}
else if (sortBy == "originalAirDate" || sortBy == "mr_original_date")
{
if (guideParams.showAirDate)
{
if (treeItem1.rawOriginalAirDate != null)
{
alternateRoot.Text = treeItem1.originalAirDate;
}
else
{
alternateRoot.Text = "No Original Air Date Found:";
}
}
else
{
alternateRoot.Text = "Original Air Date not selected to display in Configuration Tab:";
}
}
else if (sortBy == "mr_channel")
{
alternateRoot.Text = treeItem1.channelName;
}
else
{
alternateRoot.Text = treeItem1.status;
}
//Initalize the nodes
root = new TreeNode();
child1 = new TreeNode();
child2 = new TreeNode();
child3 = new TreeNode();
child4 = new TreeNode();
child5 = new TreeNode();
child6 = new TreeNode();
child7 = new TreeNode();
child8 = new TreeNode();
child9 = new TreeNode();
child10 = new TreeNode();
child11 = new TreeNode();
child12 = new TreeNode();
//Fill the intialized nodes with the info in the current item. Since this is a non-matching
//item then we also initialize the main root node.
root = FillProgrammeTree(treeItem1, guideParams, root, child1, child2, child3, child4, child5,
child6, child7, child8, child9, child10, child11, child12, true);
}
}
//Up the index of the loop
idx1++;
}
//If you are not sorting by title then load the last node filed to the grouping node and then
//the grouping node to the TreeView otherwise just load the node to the Treeview
if (sortBy != "title" && sortBy != "mr_title")
{
alternateRoot.ChildNodes.Add(root);
treeView.Nodes.Add(alternateRoot);
}
else
{
treeView.Nodes.Add(root);
}
}
private TreeNode FillProgrammeTree(ProgramTreeItem treeItem1, Settings guideParams, TreeNode root, TreeNode child1,
TreeNode child2, TreeNode child3, TreeNode child4, TreeNode child5,
TreeNode child6, TreeNode child7, TreeNode child8, TreeNode child9,
TreeNode child10, TreeNode child11, TreeNode child12, bool fillRoot)
{
//**************
//This method loads the nodes that will ultimatley be loaded into a TreeView control for displaying program
//information.
//**************
//
if (fillRoot)
{
FillProgrammeTreeTitle(treeItem1, root);
}
FillProgrammeTreeSubTitle(treeItem1, child1);
root.ChildNodes.Add(child1);
if (guideParams.showDescription)
{
FillProgrammeTreeDescription(treeItem1, child2, child3);
//If the description is empty do not display it.
if (child3.Text.Length > 0)
{
child1.ChildNodes.Add(child2);
child3.SelectAction = TreeNodeSelectAction.None;
child2.ChildNodes.Add(child3);
}
}
FillProgrammeTreeCommon(treeItem1, child4, child5, child6, child7, child8, child9, child10);
if (guideParams.showRating)
{
// Create Child Node for rating
if (child4.Text != String.Empty)
{
child4.SelectAction = TreeNodeSelectAction.None;
child1.ChildNodes.Add(child4);
}
}
if (guideParams.showGenre != "noGenre")
{
// Create Child Node for Genre
if (child5.Text != String.Empty)
{
child5.SelectAction = TreeNodeSelectAction.None;
child1.ChildNodes.Add(child5);
}
}
if (guideParams.showAirDate)
{
// Create Child Node for Release Year
if (child6.Text != String.Empty)
{
child6.SelectAction = TreeNodeSelectAction.None;
child1.ChildNodes.Add(child6);
}
}
if (guideParams.showStarRating)
{
// Create Child Node for Star Rating
if (child7.Text != String.Empty)
{
child7.SelectAction = TreeNodeSelectAction.None;
child1.ChildNodes.Add(child7);
}
}
if (guideParams.showAirDate)
{
// Create Child Node for Original Air Date
if (child8.Text != String.Empty)
{
child8.SelectAction = TreeNodeSelectAction.None;
child1.ChildNodes.Add(child8);
}
}
if (guideParams.showNew)
{
// Create Child Node for a new show
if (child9.Text != String.Empty)
{
child9.SelectAction = TreeNodeSelectAction.None;
child1.ChildNodes.Add(child9);
}
}
if (guideParams.showCredits)
{
// Create Child Node for Credits
if (child10.Text != String.Empty)
{
child10.SelectAction = TreeNodeSelectAction.None;
child1.ChildNodes.Add(child10);
}
}
//Set the 12th level of the tree for the show to the Date and time the show is available
FillProgrammeTreeAirDate(treeItem1, child11);
child11.SelectAction = TreeNodeSelectAction.None;
child11.Expand();
child1.ChildNodes.Add(child11);
//Set the 13th level of the tree for the show to the Channel which has a check box for multi-recording selection option
FillProgrammeTreeChannel(treeItem1, child12);
child12.SelectAction = TreeNodeSelectAction.None;
if (treeItem1.displayClass == "listing")
{
child12.ShowCheckBox = true;
}
child11.ChildNodes.Add(child12);
return (root);
}
#region Methods that load TreeNodes with info from a ProgrammeTreeItem Object
private void FillProgrammeTreeTitle(ProgramTreeItem treeItem, TreeNode treeNode)
{
treeNode.Text = treeItem.title;
treeNode.SelectAction = TreeNodeSelectAction.None;
treeNode.Expand();
}
private void FillProgrammeTreeSubTitle(ProgramTreeItem treeItem, TreeNode treeNode)
{
treeNode.Text = treeItem.subtitle;
if (treeItem.displayClass != "listing")
{
treeNode.Text = treeNode.Text.Replace("class=\"listing\"", "class=\"" + treeItem.displayClass + "\"");
treeNode.Text = treeNode.Text.Replace("class=\"showSubtitle\"", "class=\"" + treeItem.displayClass + "\"");
}
treeNode.SelectAction = TreeNodeSelectAction.None;
if (SortBy != null && SortBy.Length > 2)
{
if (treeItem.status == "Reocurring")
{
treeNode.Text = "Season Recording" + treeNode.Text;
}
else
{
if (treeItem.rawOriginalAirDate != null)
{
treeNode.Text = "(ad: " + treeItem.rawAirDateStartTime.ToShortDateString() + ") " + treeNode.Text + " (oad: " + treeItem.rawOriginalAirDate + ")";
}
else
{
treeNode.Text = "(ad: " + treeItem.rawAirDateStartTime.ToShortDateString() + ") " + treeNode.Text;
}
}
}
}
private void FillProgrammeTreeDescription(ProgramTreeItem treeItem, TreeNode treeNode1, TreeNode treeNode2)
{
treeNode1.Text = "Description: ";
treeNode1.SelectAction = TreeNodeSelectAction.None;
treeNode1.Expand();
treeNode2.Text = treeItem.description;
}
private void FillProgrammeTreeCommon(ProgramTreeItem treeItem, TreeNode treeNode1, TreeNode treeNode2, TreeNode treeNode3, TreeNode treeNode4, TreeNode treeNode5, TreeNode treeNode6, TreeNode treeNode7)
{
treeNode1.Text = treeItem.rating;
treeNode2.Text = treeItem.genre;
treeNode3.Text = treeItem.releaseYear;
treeNode4.Text = treeItem.starRating;
treeNode5.Text = treeItem.originalAirDate;
treeNode6.Text = treeItem.new_show;
treeNode7.Text = treeItem.credits;
}
private void FillProgrammeTreeAirDate(ProgramTreeItem treeItem, TreeNode treeNode)
{
treeNode.Text = treeItem.getAirDate();
if (treeItem.getRecordingDisplayClass() != "listing")
{
treeNode.Text = treeNode.Text.Replace("class=\"listing\"", "class=\"" + treeItem.displayClass + "\"");
}
}
private void FillProgrammeTreeChannel(ProgramTreeItem treeItem, TreeNode treeNode)
{
treeNode.Text = treeItem.channelDisplay;
treeNode.Value = treeItem.programmeOID;
treeNode.Text += treeItem.buttonOptions;
}
#endregion
}
}